

import java.util.ArrayList;

import javax.tools.JavaFileManager;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Fonction fct=new Fonction();
		
		System.out.println(fct.O());
		System.out.println(fct.I());
		System.out.println(fct.S());
		System.out.println(fct.gauche(fct.S()));
		System.out.println(fct.droite(fct.S()));
		System.out.println(fct.gauche(fct.gauche(fct.S())));
		ArrayList<String> fcs=new ArrayList<String>(); 
		fcs.add(fct.S());
		fcs.add((fct.recursion(fct.I(), fct.gauche(fct.S()))));
		
		System.out.println(fct.composition(fcs));
		System.out.println(fct.recursion(fct.I(), fct.gauche(fct.S())));
		System.out.println(f(new ArrayList<Integer>(){{ add(2); add(2);}}));
		try {
			JavaFileManager mFileManager =CompilerAPI.doMemoryCompilation("fonction1",fct.constructionClasse("fonction1", fct.recursion(fct.I(), fct.gauche(fct.S()))));
			System.out.println(CompilerAPI.executeClassFromMemory(mFileManager, new ArrayList<Integer>(){{ add(2); add(2);}}));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static int f(final ArrayList<Integer> x){return x.get(0)==0? x.get(1) : f(new ArrayList<Integer>(){{add(x.get(0)-1); addAll(x.subList(1, x.size()));}})+1;}
	
	
}
